home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1DK3KQ4 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  32.6 KB  |  1,316 lines

  1. package com.sun.java.swing;
  2.  
  3. import com.sun.java.accessibility.Accessible;
  4. import com.sun.java.accessibility.AccessibleContext;
  5. import com.sun.java.swing.border.LineBorder;
  6. import com.sun.java.swing.event.CellEditorListener;
  7. import com.sun.java.swing.event.ChangeEvent;
  8. import com.sun.java.swing.event.ListSelectionEvent;
  9. import com.sun.java.swing.event.ListSelectionListener;
  10. import com.sun.java.swing.event.TableColumnModelEvent;
  11. import com.sun.java.swing.event.TableColumnModelListener;
  12. import com.sun.java.swing.event.TableModelEvent;
  13. import com.sun.java.swing.event.TableModelListener;
  14. import com.sun.java.swing.plaf.TableUI;
  15. import com.sun.java.swing.table.DefaultTableCellRenderer;
  16. import com.sun.java.swing.table.DefaultTableColumnModel;
  17. import com.sun.java.swing.table.DefaultTableModel;
  18. import com.sun.java.swing.table.JTableHeader;
  19. import com.sun.java.swing.table.TableCellEditor;
  20. import com.sun.java.swing.table.TableCellRenderer;
  21. import com.sun.java.swing.table.TableColumn;
  22. import com.sun.java.swing.table.TableColumnModel;
  23. import com.sun.java.swing.table.TableModel;
  24. import java.awt.AWTEvent;
  25. import java.awt.Color;
  26. import java.awt.Component;
  27. import java.awt.Container;
  28. import java.awt.Dimension;
  29. import java.awt.LayoutManager;
  30. import java.awt.Point;
  31. import java.awt.Rectangle;
  32. import java.awt.event.InputEvent;
  33. import java.awt.event.MouseEvent;
  34. import java.io.IOException;
  35. import java.io.ObjectInputStream;
  36. import java.io.ObjectOutputStream;
  37. import java.util.Enumeration;
  38. import java.util.EventObject;
  39. import java.util.Hashtable;
  40. import java.util.Vector;
  41.  
  42. public class JTable extends JComponent implements TableModelListener, Scrollable, TableColumnModelListener, ListSelectionListener, CellEditorListener, Accessible {
  43.    public static final int AUTO_RESIZE_OFF = 0;
  44.    public static final int AUTO_RESIZE_LAST_COLUMN = 1;
  45.    public static final int AUTO_RESIZE_ALL_COLUMNS = 2;
  46.    protected TableModel dataModel;
  47.    protected TableColumnModel columnModel;
  48.    protected ListSelectionModel selectionModel;
  49.    protected JTableHeader tableHeader;
  50.    protected int rowHeight;
  51.    protected int rowMargin;
  52.    protected Color gridColor;
  53.    protected boolean showHorizontalLines;
  54.    protected boolean showVerticalLines;
  55.    protected int autoResizeMode;
  56.    protected boolean autoCreateColumnsFromModel;
  57.    protected Dimension preferredViewportSize;
  58.    protected boolean rowSelectionAllowed;
  59.    protected boolean cellSelectionEnabled;
  60.    protected transient Component editorComp;
  61.    protected transient TableCellEditor cellEditor;
  62.    protected transient int editingColumn;
  63.    protected transient int editingRow;
  64.    protected transient Hashtable defaultRenderersByColumnClass;
  65.    protected transient Hashtable defaultEditorsByColumnClass;
  66.    protected Color selectionForeground;
  67.    protected Color selectionBackground;
  68.    static Class class$java$lang$Object;
  69.    static Class class$java$lang$Boolean;
  70.    static Class class$com$sun$java$swing$ImageIcon;
  71.    static Class class$java$lang$Number;
  72.  
  73.    public JTable() {
  74.       this((TableModel)null, (TableColumnModel)null, (ListSelectionModel)null);
  75.    }
  76.  
  77.    public JTable(Object[][] rowData, Object[] columnNames) {
  78.       this(new 1(rowData, columnNames));
  79.    }
  80.  
  81.    public JTable(int numRows, int numColumns) {
  82.       this(new DefaultTableModel(numRows, numColumns));
  83.    }
  84.  
  85.    public JTable(TableModel dm) {
  86.       this(dm, (TableColumnModel)null, (ListSelectionModel)null);
  87.    }
  88.  
  89.    public JTable(TableModel dm, TableColumnModel cm) {
  90.       this(dm, cm, (ListSelectionModel)null);
  91.    }
  92.  
  93.    public JTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) {
  94.       ((Container)this).setLayout((LayoutManager)null);
  95.       if (cm == null) {
  96.          cm = this.createDefaultColumnModel();
  97.          this.autoCreateColumnsFromModel = true;
  98.       }
  99.  
  100.       this.setColumnModel(cm);
  101.       if (sm == null) {
  102.          sm = this.createDefaultSelectionModel();
  103.       }
  104.  
  105.       this.setSelectionModel(sm);
  106.       if (dm == null) {
  107.          dm = this.createDefaultDataModel();
  108.       }
  109.  
  110.       this.setModel(dm);
  111.       this.initializeLocalVars();
  112.       this.updateUI();
  113.    }
  114.  
  115.    public JTable(Vector rowData, Vector columnNames) {
  116.       this(new 2(rowData, columnNames));
  117.    }
  118.  
  119.    public void addColumn(TableColumn aColumn) {
  120.       int modelColumn = aColumn.getModelIndex();
  121.       String columnName = this.getModel().getColumnName(modelColumn);
  122.       if (aColumn.getHeaderValue() == null) {
  123.          aColumn.setHeaderValue(columnName);
  124.       }
  125.  
  126.       this.getColumnModel().addColumn(aColumn);
  127.    }
  128.  
  129.    public void addColumnSelectionInterval(int index0, int index1) {
  130.       this.columnModel.getSelectionModel().addSelectionInterval(index0, index1);
  131.    }
  132.  
  133.    public void addNotify() {
  134.       super.addNotify();
  135.       this.configureEnclosingScrollPane();
  136.    }
  137.  
  138.    public void addRowSelectionInterval(int index0, int index1) {
  139.       this.selectionModel.addSelectionInterval(index0, index1);
  140.    }
  141.  
  142.    public void clearSelection() {
  143.       this.columnModel.getSelectionModel().clearSelection();
  144.       this.selectionModel.clearSelection();
  145.    }
  146.  
  147.    public void columnAdded(TableColumnModelEvent e) {
  148.       if (this.isEditing()) {
  149.          this.removeEditor();
  150.       }
  151.  
  152.       this.resizeAndRepaint();
  153.    }
  154.  
  155.    public int columnAtPoint(Point point) {
  156.       return this.getColumnModel().getColumnIndexAtX(point.x);
  157.    }
  158.  
  159.    public void columnMarginChanged(ChangeEvent e) {
  160.       if (this.isEditing()) {
  161.          this.removeEditor();
  162.       }
  163.  
  164.       this.resizeAndRepaint();
  165.    }
  166.  
  167.    public void columnMoved(TableColumnModelEvent e) {
  168.       if (this.isEditing()) {
  169.          this.removeEditor();
  170.       }
  171.  
  172.       ((Component)this).repaint();
  173.    }
  174.  
  175.    public void columnRemoved(TableColumnModelEvent e) {
  176.       if (this.isEditing()) {
  177.          this.removeEditor();
  178.       }
  179.  
  180.       this.resizeAndRepaint();
  181.    }
  182.  
  183.    public void columnSelectionChanged(ListSelectionEvent e) {
  184.       int firstIndex = e.getFirstIndex();
  185.       int lastIndex = e.getLastIndex();
  186.       if (firstIndex == -1 && lastIndex == -1) {
  187.          ((Component)this).repaint();
  188.       }
  189.  
  190.       Rectangle firstColumnRect = this.getCellRect(0, firstIndex, false);
  191.       Rectangle lastColumnRect = this.getCellRect(this.getRowCount(), lastIndex, false);
  192.       Rectangle dirtyRegion = firstColumnRect.union(lastColumnRect);
  193.       ((Component)this).repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
  194.    }
  195.  
  196.    protected void configureEnclosingScrollPane() {
  197.       Container p = ((Component)this).getParent();
  198.       if (p instanceof JViewport) {
  199.          Container gp = ((Component)p).getParent();
  200.          if (gp instanceof JScrollPane) {
  201.             JScrollPane scrollPane = (JScrollPane)gp;
  202.             JViewport viewport = scrollPane.getViewport();
  203.             if (viewport == null || viewport.getView() != this) {
  204.                return;
  205.             }
  206.  
  207.             scrollPane.setColumnHeaderView(this.getTableHeader());
  208.             scrollPane.getViewport().setBackingStoreEnabled(true);
  209.             ((JComponent)scrollPane).setBorder(UIManager.getBorder("Table.scrollPaneBorder"));
  210.          }
  211.       }
  212.  
  213.    }
  214.  
  215.    public int convertColumnIndexToModel(int viewColumnIndex) {
  216.       return viewColumnIndex < 0 ? viewColumnIndex : this.getColumnModel().getColumn(viewColumnIndex).getModelIndex();
  217.    }
  218.  
  219.    public int convertColumnIndexToView(int modelColumnIndex) {
  220.       if (modelColumnIndex < 0) {
  221.          return modelColumnIndex;
  222.       } else {
  223.          TableColumnModel cm = this.getColumnModel();
  224.  
  225.          for(int column = 0; column < this.getColumnCount(); ++column) {
  226.             if (cm.getColumn(column).getModelIndex() == modelColumnIndex) {
  227.                return column;
  228.             }
  229.          }
  230.  
  231.          return -1;
  232.       }
  233.    }
  234.  
  235.    protected TableColumnModel createDefaultColumnModel() {
  236.       return new DefaultTableColumnModel();
  237.    }
  238.  
  239.    public void createDefaultColumnsFromModel() {
  240.       TableModel m = this.getModel();
  241.       if (m != null) {
  242.          TableColumnModel cm = this.getColumnModel();
  243.          cm.removeColumnModelListener(this);
  244.  
  245.          while(cm.getColumnCount() > 0) {
  246.             cm.removeColumn(cm.getColumn(0));
  247.          }
  248.  
  249.          for(int i = 0; i < m.getColumnCount(); ++i) {
  250.             TableColumn newColumn = new TableColumn(i);
  251.             this.addColumn(newColumn);
  252.          }
  253.  
  254.          cm.addColumnModelListener(this);
  255.       }
  256.  
  257.    }
  258.  
  259.    protected TableModel createDefaultDataModel() {
  260.       return new DefaultTableModel();
  261.    }
  262.  
  263.    protected void createDefaultEditors() {
  264.       this.defaultEditorsByColumnClass = new Hashtable();
  265.       JTextField textField = new JTextField();
  266.       ((JComponent)textField).setBorder(new LineBorder(Color.black));
  267.       Class var10001 = class$java$lang$Object;
  268.       if (var10001 == null) {
  269.          try {
  270.             var10001 = Class.forName("java.lang.Object");
  271.          } catch (ClassNotFoundException var6) {
  272.             throw new NoClassDefFoundError(((Throwable)var6).getMessage());
  273.          }
  274.  
  275.          class$java$lang$Object = var10001;
  276.       }
  277.  
  278.       this.setDefaultEditor(var10001, new DefaultCellEditor(textField));
  279.       JTextField rightAlignedTextField = new JTextField();
  280.       rightAlignedTextField.setHorizontalAlignment(4);
  281.       ((JComponent)rightAlignedTextField).setBorder(new LineBorder(Color.black));
  282.       var10001 = class$java$lang$Number;
  283.       if (var10001 == null) {
  284.          try {
  285.             var10001 = Class.forName("java.lang.Number");
  286.          } catch (ClassNotFoundException var5) {
  287.             throw new NoClassDefFoundError(((Throwable)var5).getMessage());
  288.          }
  289.  
  290.          class$java$lang$Number = var10001;
  291.       }
  292.  
  293.       this.setDefaultEditor(var10001, new DefaultCellEditor(rightAlignedTextField));
  294.       JCheckBox centeredCheckBox = new JCheckBox();
  295.       ((AbstractButton)centeredCheckBox).setHorizontalAlignment(0);
  296.       var10001 = class$java$lang$Boolean;
  297.       if (var10001 == null) {
  298.          try {
  299.             var10001 = Class.forName("java.lang.Boolean");
  300.          } catch (ClassNotFoundException var4) {
  301.             throw new NoClassDefFoundError(((Throwable)var4).getMessage());
  302.          }
  303.  
  304.          class$java$lang$Boolean = var10001;
  305.       }
  306.  
  307.       this.setDefaultEditor(var10001, new DefaultCellEditor(centeredCheckBox));
  308.    }
  309.  
  310.    protected void createDefaultRenderers() {
  311.       this.defaultRenderersByColumnClass = new Hashtable();
  312.       DefaultTableCellRenderer label = new DefaultTableCellRenderer();
  313.       Class var10001 = class$java$lang$Object;
  314.       if (var10001 == null) {
  315.          try {
  316.             var10001 = Class.forName("java.lang.Object");
  317.          } catch (ClassNotFoundException var8) {
  318.             throw new NoClassDefFoundError(((Throwable)var8).getMessage());
  319.          }
  320.  
  321.          class$java$lang$Object = var10001;
  322.       }
  323.  
  324.       this.setDefaultRenderer(var10001, label);
  325.       DefaultTableCellRenderer rightAlignedLabel = new DefaultTableCellRenderer();
  326.       ((JLabel)rightAlignedLabel).setHorizontalAlignment(4);
  327.       var10001 = class$java$lang$Number;
  328.       if (var10001 == null) {
  329.          try {
  330.             var10001 = Class.forName("java.lang.Number");
  331.          } catch (ClassNotFoundException var7) {
  332.             throw new NoClassDefFoundError(((Throwable)var7).getMessage());
  333.          }
  334.  
  335.          class$java$lang$Number = var10001;
  336.       }
  337.  
  338.       this.setDefaultRenderer(var10001, rightAlignedLabel);
  339.       DefaultTableCellRenderer centeredLabel = new 3();
  340.       ((JLabel)centeredLabel).setHorizontalAlignment(0);
  341.       var10001 = class$com$sun$java$swing$ImageIcon;
  342.       if (var10001 == null) {
  343.          try {
  344.             var10001 = Class.forName("com.sun.java.swing.ImageIcon");
  345.          } catch (ClassNotFoundException var6) {
  346.             throw new NoClassDefFoundError(((Throwable)var6).getMessage());
  347.          }
  348.  
  349.          class$com$sun$java$swing$ImageIcon = var10001;
  350.       }
  351.  
  352.       this.setDefaultRenderer(var10001, centeredLabel);
  353.       CheckBoxRenderer booleanRenderer = new CheckBoxRenderer(this);
  354.       ((AbstractButton)booleanRenderer).setHorizontalAlignment(0);
  355.       var10001 = class$java$lang$Boolean;
  356.       if (var10001 == null) {
  357.          try {
  358.             var10001 = Class.forName("java.lang.Boolean");
  359.          } catch (ClassNotFoundException var5) {
  360.             throw new NoClassDefFoundError(((Throwable)var5).getMessage());
  361.          }
  362.  
  363.          class$java$lang$Boolean = var10001;
  364.       }
  365.  
  366.       this.setDefaultRenderer(var10001, booleanRenderer);
  367.    }
  368.  
  369.    protected ListSelectionModel createDefaultSelectionModel() {
  370.       DefaultListSelectionModel m = new DefaultListSelectionModel();
  371.       m.setLeadAnchorNotificationEnabled(false);
  372.       return m;
  373.    }
  374.  
  375.    protected JTableHeader createDefaultTableHeader() {
  376.       return new JTableHeader(this.columnModel);
  377.    }
  378.  
  379.    /** @deprecated */
  380.    public static JScrollPane createScrollPaneForTable(JTable aTable) {
  381.       return new JScrollPane(aTable);
  382.    }
  383.  
  384.    public boolean editCellAt(int row, int column) {
  385.       return this.editCellAt(row, column, (EventObject)null);
  386.    }
  387.  
  388.    public boolean editCellAt(int row, int column, EventObject e) {
  389.       if (!this.isCellEditable(row, column)) {
  390.          return false;
  391.       } else {
  392.          if (this.isEditing() && this.cellEditor != null) {
  393.             boolean stopped = this.cellEditor.stopCellEditing();
  394.             if (!stopped) {
  395.                return false;
  396.             }
  397.          }
  398.  
  399.          TableColumn tableColumn = this.getColumnModel().getColumn(column);
  400.          TableCellEditor editor = tableColumn.getCellEditor();
  401.          if (editor == null) {
  402.             editor = this.getDefaultEditor(this.getColumnClass(column));
  403.          }
  404.  
  405.          if (editor != null) {
  406.             this.editorComp = this.prepareEditor(editor, row, column);
  407.             if (editor.isCellEditable(e)) {
  408.                this.editorComp.setBounds(this.getCellRect(row, column, false));
  409.                ((Container)this).add(this.editorComp);
  410.                this.editorComp.validate();
  411.                editor.shouldSelectCell(e);
  412.                this.setCellEditor(editor);
  413.                this.setEditingRow(row);
  414.                this.setEditingColumn(column);
  415.                editor.addCellEditorListener(this);
  416.                ((Component)this).repaint();
  417.                return true;
  418.             }
  419.          }
  420.  
  421.          return false;
  422.       }
  423.    }
  424.  
  425.    public void editingCanceled(ChangeEvent e) {
  426.       this.removeEditor();
  427.    }
  428.  
  429.    public void editingStopped(ChangeEvent e) {
  430.       TableCellEditor editor = this.getCellEditor();
  431.       if (editor != null) {
  432.          Object value = editor.getCellEditorValue();
  433.          this.setValueAt(value, this.editingRow, this.editingColumn);
  434.          this.removeEditor();
  435.       }
  436.  
  437.    }
  438.  
  439.    public AccessibleContext getAccessibleContext() {
  440.       if (super.accessibleContext == null) {
  441.          super.accessibleContext = new AccessibleJTable(this);
  442.       }
  443.  
  444.       return super.accessibleContext;
  445.    }
  446.  
  447.    public boolean getAutoCreateColumnsFromModel() {
  448.       return this.autoCreateColumnsFromModel;
  449.    }
  450.  
  451.    public int getAutoResizeMode() {
  452.       return this.autoResizeMode;
  453.    }
  454.  
  455.    public TableCellEditor getCellEditor() {
  456.       return this.cellEditor;
  457.    }
  458.  
  459.    public Rectangle getCellRect(int row, int column, boolean includeSpacing) {
  460.       int index = 0;
  461.       int columnMargin = this.getColumnModel().getColumnMargin();
  462.       Enumeration enumeration = this.getColumnModel().getColumns();
  463.       Rectangle cellFrame = new Rectangle();
  464.       cellFrame.height = this.getRowHeight() + this.rowMargin;
  465.  
  466.       for(cellFrame.y = row * cellFrame.height; enumeration.hasMoreElements(); ++index) {
  467.          TableColumn aColumn = (TableColumn)enumeration.nextElement();
  468.          cellFrame.width = aColumn.getWidth() + columnMargin;
  469.          if (index == column) {
  470.             break;
  471.          }
  472.  
  473.          cellFrame.x += cellFrame.width;
  474.       }
  475.  
  476.       if (!includeSpacing) {
  477.          Dimension spacing = this.getIntercellSpacing();
  478.          cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2, cellFrame.width - spacing.width, cellFrame.height - spacing.height);
  479.       }
  480.  
  481.       return cellFrame;
  482.    }
  483.  
  484.    public boolean getCellSelectionEnabled() {
  485.       return this.cellSelectionEnabled;
  486.    }
  487.  
  488.    public TableColumn getColumn(Object identifier) {
  489.       TableColumnModel cm = this.getColumnModel();
  490.       int columnIndex = cm.getColumnIndex(identifier);
  491.       return cm.getColumn(columnIndex);
  492.    }
  493.  
  494.    public Class getColumnClass(int column) {
  495.       return this.getModel().getColumnClass(this.convertColumnIndexToModel(column));
  496.    }
  497.  
  498.    public int getColumnCount() {
  499.       return this.getColumnModel().getColumnCount();
  500.    }
  501.  
  502.    public TableColumnModel getColumnModel() {
  503.       return this.columnModel;
  504.    }
  505.  
  506.    public String getColumnName(int column) {
  507.       return this.getModel().getColumnName(this.convertColumnIndexToModel(column));
  508.    }
  509.  
  510.    public boolean getColumnSelectionAllowed() {
  511.       return this.columnModel.getColumnSelectionAllowed();
  512.    }
  513.  
  514.    public TableCellEditor getDefaultEditor(Class columnClass) {
  515.       if (columnClass == null) {
  516.          return null;
  517.       } else {
  518.          Object editor = this.defaultEditorsByColumnClass.get(columnClass);
  519.          return editor != null ? (TableCellEditor)editor : this.getDefaultEditor(columnClass.getSuperclass());
  520.       }
  521.    }
  522.  
  523.    public TableCellRenderer getDefaultRenderer(Class columnClass) {
  524.       if (columnClass == null) {
  525.          return null;
  526.       } else {
  527.          Object renderer = this.defaultRenderersByColumnClass.get(columnClass);
  528.          return renderer != null ? (TableCellRenderer)renderer : this.getDefaultRenderer(columnClass.getSuperclass());
  529.       }
  530.    }
  531.  
  532.    public int getEditingColumn() {
  533.       return this.editingColumn;
  534.    }
  535.  
  536.    public int getEditingRow() {
  537.       return this.editingRow;
  538.    }
  539.  
  540.    public Component getEditorComponent() {
  541.       return this.editorComp;
  542.    }
  543.  
  544.    public Color getGridColor() {
  545.       return this.gridColor;
  546.    }
  547.  
  548.    public Dimension getIntercellSpacing() {
  549.       return new Dimension(this.getColumnModel().getColumnMargin(), this.rowMargin);
  550.    }
  551.  
  552.    public TableModel getModel() {
  553.       return this.dataModel;
  554.    }
  555.  
  556.    public Dimension getPreferredScrollableViewportSize() {
  557.       return this.preferredViewportSize;
  558.    }
  559.  
  560.    public int getRowCount() {
  561.       return this.getModel().getRowCount();
  562.    }
  563.  
  564.    public int getRowHeight() {
  565.       return this.rowHeight;
  566.    }
  567.  
  568.    public boolean getRowSelectionAllowed() {
  569.       return this.rowSelectionAllowed;
  570.    }
  571.  
  572.    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
  573.       return orientation == 1 ? visibleRect.height : visibleRect.width;
  574.    }
  575.  
  576.    public boolean getScrollableTracksViewportHeight() {
  577.       return false;
  578.    }
  579.  
  580.    public boolean getScrollableTracksViewportWidth() {
  581.       return false;
  582.    }
  583.  
  584.    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
  585.       return orientation == 0 ? 1 : this.rowHeight;
  586.    }
  587.  
  588.    public int getSelectedColumn() {
  589.       return this.columnModel.getSelectionModel().getAnchorSelectionIndex();
  590.    }
  591.  
  592.    public int getSelectedColumnCount() {
  593.       return this.columnModel.getSelectedColumnCount();
  594.    }
  595.  
  596.    public int[] getSelectedColumns() {
  597.       return this.columnModel.getSelectedColumns();
  598.    }
  599.  
  600.    public int getSelectedRow() {
  601.       return this.selectionModel != null ? this.selectionModel.getAnchorSelectionIndex() : -1;
  602.    }
  603.  
  604.    public int getSelectedRowCount() {
  605.       if (this.selectionModel != null) {
  606.          int iMin = this.selectionModel.getMinSelectionIndex();
  607.          int iMax = this.selectionModel.getMaxSelectionIndex();
  608.          int count = 0;
  609.  
  610.          for(int i = iMin; i <= iMax; ++i) {
  611.             if (this.selectionModel.isSelectedIndex(i)) {
  612.                ++count;
  613.             }
  614.          }
  615.  
  616.          return count;
  617.       } else {
  618.          return 0;
  619.       }
  620.    }
  621.  
  622.    public int[] getSelectedRows() {
  623.       if (this.selectionModel != null) {
  624.          int iMin = this.selectionModel.getMinSelectionIndex();
  625.          int iMax = this.selectionModel.getMaxSelectionIndex();
  626.          if (iMin != -1 && iMax != -1) {
  627.             int[] rvTmp = new int[1 + (iMax - iMin)];
  628.             int n = 0;
  629.  
  630.             for(int i = iMin; i <= iMax; ++i) {
  631.                if (this.selectionModel.isSelectedIndex(i)) {
  632.                   rvTmp[n++] = i;
  633.                }
  634.             }
  635.  
  636.             int[] rv = new int[n];
  637.             System.arraycopy(rvTmp, 0, rv, 0, n);
  638.             return rv;
  639.          } else {
  640.             return new int[0];
  641.          }
  642.       } else {
  643.          return new int[0];
  644.       }
  645.    }
  646.  
  647.    public Color getSelectionBackground() {
  648.       return this.selectionBackground;
  649.    }
  650.  
  651.    public Color getSelectionForeground() {
  652.       return this.selectionForeground;
  653.    }
  654.  
  655.    public ListSelectionModel getSelectionModel() {
  656.       return this.selectionModel;
  657.    }
  658.  
  659.    public boolean getShowHorizontalLines() {
  660.       return this.showHorizontalLines;
  661.    }
  662.  
  663.    public boolean getShowVerticalLines() {
  664.       return this.showVerticalLines;
  665.    }
  666.  
  667.    public JTableHeader getTableHeader() {
  668.       return this.tableHeader;
  669.    }
  670.  
  671.    public String getToolTipText(MouseEvent event) {
  672.       String tip = null;
  673.       Point p = event.getPoint();
  674.       int hitColumnIndex = this.columnAtPoint(p);
  675.       int hitRowIndex = this.rowAtPoint(p);
  676.       if (hitColumnIndex != -1 && hitRowIndex != -1) {
  677.          TableColumn aColumn = this.getColumnModel().getColumn(hitColumnIndex);
  678.          TableCellRenderer renderer = aColumn.getCellRenderer();
  679.          if (renderer == null) {
  680.             Class columnClass = this.getColumnClass(hitColumnIndex);
  681.             renderer = this.getDefaultRenderer(columnClass);
  682.          }
  683.  
  684.          Component component = renderer.getTableCellRendererComponent(this, (Object)null, false, false, hitRowIndex, hitColumnIndex);
  685.          if (component instanceof JComponent) {
  686.             Rectangle cellRect = this.getCellRect(hitRowIndex, hitColumnIndex, false);
  687.             p.translate(-cellRect.x, -cellRect.y);
  688.             MouseEvent newEvent = new MouseEvent(component, ((AWTEvent)event).getID(), ((InputEvent)event).getWhen(), ((InputEvent)event).getModifiers(), p.x, p.y, event.getClickCount(), event.isPopupTrigger());
  689.             tip = ((JComponent)component).getToolTipText(newEvent);
  690.          }
  691.       }
  692.  
  693.       if (tip == null) {
  694.          tip = ((JComponent)this).getToolTipText();
  695.       }
  696.  
  697.       return tip;
  698.    }
  699.  
  700.    public TableUI getUI() {
  701.       return (TableUI)super.ui;
  702.    }
  703.  
  704.    public String getUIClassID() {
  705.       return "TableUI";
  706.    }
  707.  
  708.    public Object getValueAt(int row, int column) {
  709.       return this.getModel().getValueAt(row, this.convertColumnIndexToModel(column));
  710.    }
  711.  
  712.    protected void initializeLocalVars() {
  713.       this.createDefaultRenderers();
  714.       this.createDefaultEditors();
  715.       this.setTableHeader(this.createDefaultTableHeader());
  716.       this.setShowGrid(true);
  717.       this.setAutoResizeMode(2);
  718.       this.setRowHeight(16);
  719.       this.rowMargin = 1;
  720.       this.setSelectionMode(2);
  721.       this.setColumnSelectionAllowed(false);
  722.       this.setRowSelectionAllowed(true);
  723.       this.setCellSelectionEnabled(false);
  724.       this.cellEditor = null;
  725.       this.editingColumn = this.editingRow = -1;
  726.       this.preferredViewportSize = new Dimension(450, 400);
  727.       ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
  728.       toolTipManager.registerComponent(this);
  729.       ((JComponent)this).setAutoscrolls(true);
  730.       this.tableHeader.setAutoscrolls(true);
  731.    }
  732.  
  733.    public boolean isCellEditable(int row, int column) {
  734.       return this.getModel().isCellEditable(row, this.convertColumnIndexToModel(column));
  735.    }
  736.  
  737.    public boolean isCellSelected(int row, int column) {
  738.       if (this.cellSelectionEnabled) {
  739.          return this.isRowSelected(row) && this.isColumnSelected(column);
  740.       } else {
  741.          return this.getRowSelectionAllowed() && this.isRowSelected(row) || this.getColumnSelectionAllowed() && this.isColumnSelected(column);
  742.       }
  743.    }
  744.  
  745.    public boolean isColumnSelected(int column) {
  746.       return this.columnModel.getSelectionModel().isSelectedIndex(column);
  747.    }
  748.  
  749.    public boolean isEditing() {
  750.       return this.cellEditor != null;
  751.    }
  752.  
  753.    public boolean isOpaque() {
  754.       return true;
  755.    }
  756.  
  757.    public boolean isRowSelected(int row) {
  758.       return this.selectionModel != null ? this.selectionModel.isSelectedIndex(row) : false;
  759.    }
  760.  
  761.    public void moveColumn(int column, int targetColumn) {
  762.       this.getColumnModel().moveColumn(column, targetColumn);
  763.    }
  764.  
  765.    public Component prepareEditor(TableCellEditor editor, int row, int column) {
  766.       Object value = this.getValueAt(row, column);
  767.       this.getColumnModel().getColumn(column);
  768.       boolean isSelected = this.isCellSelected(row, column);
  769.       Component comp = editor.getTableCellEditorComponent(this, value, isSelected, row, column);
  770.       if (comp != null && comp.getFont() == null) {
  771.          comp.setFont(((Component)this).getFont());
  772.       }
  773.  
  774.       return comp;
  775.    }
  776.  
  777.    private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
  778.       s.defaultReadObject();
  779.       this.createDefaultRenderers();
  780.       this.createDefaultEditors();
  781.    }
  782.  
  783.    public void removeColumn(TableColumn aColumn) {
  784.       this.getColumnModel().removeColumn(aColumn);
  785.    }
  786.  
  787.    public void removeColumnSelectionInterval(int index0, int index1) {
  788.       this.columnModel.getSelectionModel().removeSelectionInterval(index0, index1);
  789.    }
  790.  
  791.    public void removeEditor() {
  792.       TableCellEditor editor = this.getCellEditor();
  793.       if (editor != null) {
  794.          editor.removeCellEditorListener(this);
  795.          if (this.editorComp instanceof JComboBox) {
  796.             ((JComboBox)this.editorComp).hidePopup();
  797.          }
  798.  
  799.          ((Container)this).remove(this.editorComp);
  800.          Rectangle cellRect = this.getCellRect(this.editingRow, this.editingColumn, false);
  801.          ((Component)this).repaint(cellRect.x, cellRect.y, cellRect.width, cellRect.height);
  802.          if (!(this.editorComp instanceof JComponent) || ((JComponent)this.editorComp).hasFocus()) {
  803.             ((JComponent)this).requestFocus();
  804.          }
  805.  
  806.          this.setCellEditor((TableCellEditor)null);
  807.          this.setEditingColumn(-1);
  808.          this.setEditingRow(-1);
  809.          this.editorComp = null;
  810.       }
  811.  
  812.    }
  813.  
  814.    public void removeRowSelectionInterval(int index0, int index1) {
  815.       this.selectionModel.removeSelectionInterval(index0, index1);
  816.    }
  817.  
  818.    protected void resizeAndRepaint() {
  819.       ((JComponent)this).revalidate();
  820.       ((Component)this).repaint();
  821.    }
  822.  
  823.    public int rowAtPoint(Point point) {
  824.       int y = point.y;
  825.       int rowHeight = this.getRowHeight();
  826.       int rowSpacing = this.getIntercellSpacing().height;
  827.       int totalRowHeight = rowHeight + rowSpacing;
  828.       int result = y / totalRowHeight;
  829.       if (result < 0) {
  830.          return -1;
  831.       } else {
  832.          return result >= this.getRowCount() ? -1 : result;
  833.       }
  834.    }
  835.  
  836.    public void selectAll() {
  837.       if (this.getSelectedRowCount() > 0) {
  838.          int count = this.getRowCount();
  839.          if (count > 0) {
  840.             this.setRowSelectionInterval(0, count);
  841.          }
  842.       }
  843.  
  844.       if (this.getSelectedColumnCount() > 0) {
  845.          int count = this.getColumnCount();
  846.          if (count > 0) {
  847.             this.setColumnSelectionInterval(0, count);
  848.          }
  849.       }
  850.  
  851.    }
  852.  
  853.    public void setAutoCreateColumnsFromModel(boolean createColumns) {
  854.       if (this.autoCreateColumnsFromModel != createColumns) {
  855.          this.autoCreateColumnsFromModel = createColumns;
  856.          if (this.autoCreateColumnsFromModel) {
  857.             this.createDefaultColumnsFromModel();
  858.          }
  859.       }
  860.  
  861.    }
  862.  
  863.    public void setAutoResizeMode(int mode) {
  864.       if (mode == 2 || mode == 1 || mode == 0) {
  865.          this.autoResizeMode = mode;
  866.          this.resizeAndRepaint();
  867.          this.tableHeader.resizeAndRepaint();
  868.       }
  869.  
  870.    }
  871.  
  872.    public void setCellEditor(TableCellEditor anEditor) {
  873.       this.cellEditor = anEditor;
  874.    }
  875.  
  876.    public void setCellSelectionEnabled(boolean flag) {
  877.       this.clearSelection();
  878.       this.cellSelectionEnabled = flag;
  879.    }
  880.  
  881.    public void setColumnModel(TableColumnModel newModel) {
  882.       if (newModel == null) {
  883.          throw new IllegalArgumentException("Cannot set a null ColumnModel");
  884.       } else {
  885.          TableColumnModel oldModel = this.columnModel;
  886.          if (newModel != oldModel) {
  887.             if (oldModel != null) {
  888.                oldModel.removeColumnModelListener(this);
  889.             }
  890.  
  891.             this.columnModel = newModel;
  892.             newModel.addColumnModelListener(this);
  893.             if (this.tableHeader != null) {
  894.                this.tableHeader.setColumnModel(newModel);
  895.             }
  896.  
  897.             this.resizeAndRepaint();
  898.          }
  899.  
  900.       }
  901.    }
  902.  
  903.    public void setColumnSelectionAllowed(boolean flag) {
  904.       this.clearSelection();
  905.       this.columnModel.setColumnSelectionAllowed(flag);
  906.    }
  907.  
  908.    public void setColumnSelectionInterval(int index0, int index1) {
  909.       this.columnModel.getSelectionModel().setSelectionInterval(index0, index1);
  910.    }
  911.  
  912.    public void setDefaultEditor(Class columnClass, TableCellEditor editor) {
  913.       this.defaultEditorsByColumnClass.put(columnClass, editor);
  914.    }
  915.  
  916.    public void setDefaultRenderer(Class columnClass, TableCellRenderer renderer) {
  917.       this.defaultRenderersByColumnClass.put(columnClass, renderer);
  918.    }
  919.  
  920.    public void setEditingColumn(int aColumn) {
  921.       this.editingColumn = aColumn;
  922.    }
  923.  
  924.    public void setEditingRow(int aRow) {
  925.       this.editingRow = aRow;
  926.    }
  927.  
  928.    public void setGridColor(Color newColor) {
  929.       if (newColor == null) {
  930.          throw new IllegalArgumentException("New color is null");
  931.       } else {
  932.          this.gridColor = newColor;
  933.          ((Component)this).repaint();
  934.       }
  935.    }
  936.  
  937.    public void setIntercellSpacing(Dimension newSpacing) {
  938.       this.rowMargin = newSpacing.height;
  939.       this.getColumnModel().setColumnMargin(newSpacing.width);
  940.       this.resizeAndRepaint();
  941.    }
  942.  
  943.    public void setModel(TableModel newModel) {
  944.       TableModel oldModel = this.dataModel;
  945.       if (newModel == null) {
  946.          throw new IllegalArgumentException("Cannot set a null TableModel");
  947.       } else {
  948.          if (newModel != oldModel) {
  949.             if (oldModel != null) {
  950.                oldModel.removeTableModelListener(this);
  951.             }
  952.  
  953.             this.dataModel = newModel;
  954.             newModel.addTableModelListener(this);
  955.             if (this.getColumnModel() != null) {
  956.                this.tableChanged(new TableModelEvent(this.dataModel, -1));
  957.             }
  958.          }
  959.  
  960.       }
  961.    }
  962.  
  963.    public void setPreferredScrollableViewportSize(Dimension size) {
  964.       this.preferredViewportSize = size;
  965.    }
  966.  
  967.    public void setRowHeight(int newHeight) {
  968.       if (newHeight <= 0) {
  969.          throw new IllegalArgumentException("New row height less than 1");
  970.       } else {
  971.          this.rowHeight = newHeight;
  972.          this.resizeAndRepaint();
  973.       }
  974.    }
  975.  
  976.    public void setRowSelectionAllowed(boolean flag) {
  977.       this.clearSelection();
  978.       this.rowSelectionAllowed = flag;
  979.    }
  980.  
  981.    public void setRowSelectionInterval(int index0, int index1) {
  982.       this.selectionModel.setSelectionInterval(index0, index1);
  983.    }
  984.  
  985.    public void setSelectionBackground(Color selectionBackground) {
  986.       Color oldValue = this.selectionBackground;
  987.       this.selectionBackground = selectionBackground;
  988.       ((JComponent)this).firePropertyChange("selectionBackground", oldValue, selectionBackground);
  989.    }
  990.  
  991.    public void setSelectionForeground(Color selectionForeground) {
  992.       Color oldValue = this.selectionForeground;
  993.       this.selectionForeground = selectionForeground;
  994.       ((JComponent)this).firePropertyChange("selectionForeground", oldValue, selectionForeground);
  995.    }
  996.  
  997.    public void setSelectionMode(int selectionMode) {
  998.       this.clearSelection();
  999.       this.getSelectionModel().setSelectionMode(selectionMode);
  1000.       this.getColumnModel().getSelectionModel().setSelectionMode(selectionMode);
  1001.    }
  1002.  
  1003.    public void setSelectionModel(ListSelectionModel newModel) {
  1004.       if (newModel == null) {
  1005.          throw new IllegalArgumentException("Cannot set a null SelectionModel");
  1006.       } else {
  1007.          ListSelectionModel oldModel = this.selectionModel;
  1008.          if (newModel != oldModel) {
  1009.             if (oldModel != null) {
  1010.                oldModel.removeListSelectionListener(this);
  1011.             }
  1012.  
  1013.             this.selectionModel = newModel;
  1014.             if (newModel != null) {
  1015.                newModel.addListSelectionListener(this);
  1016.             }
  1017.  
  1018.             ((Component)this).repaint();
  1019.          }
  1020.  
  1021.       }
  1022.    }
  1023.  
  1024.    public void setShowGrid(boolean b) {
  1025.       this.setShowHorizontalLines(b);
  1026.       this.setShowVerticalLines(b);
  1027.       ((Component)this).repaint();
  1028.    }
  1029.  
  1030.    public void setShowHorizontalLines(boolean b) {
  1031.       this.showHorizontalLines = b;
  1032.       ((Component)this).repaint();
  1033.    }
  1034.  
  1035.    public void setShowVerticalLines(boolean b) {
  1036.       this.showVerticalLines = b;
  1037.       ((Component)this).repaint();
  1038.    }
  1039.  
  1040.    public void setTableHeader(JTableHeader newHeader) {
  1041.       if (this.tableHeader != newHeader) {
  1042.          if (this.tableHeader != null) {
  1043.             this.tableHeader.setTable((JTable)null);
  1044.          }
  1045.  
  1046.          this.tableHeader = newHeader;
  1047.          if (this.tableHeader != null) {
  1048.             this.tableHeader.setTable(this);
  1049.          }
  1050.       }
  1051.  
  1052.    }
  1053.  
  1054.    public void setUI(TableUI ui) {
  1055.       if (super.ui != ui) {
  1056.          super.setUI(ui);
  1057.          ((Component)this).repaint();
  1058.       }
  1059.  
  1060.    }
  1061.  
  1062.    public void setValueAt(Object aValue, int row, int column) {
  1063.       this.getModel().setValueAt(aValue, row, this.convertColumnIndexToModel(column));
  1064.    }
  1065.  
  1066.    public void sizeColumnsToFit(boolean lastColumnOnly) {
  1067.       int intercellWidth = this.getColumnModel().getColumnMargin();
  1068.       int frameWidth = ((JComponent)this).getWidth();
  1069.       int totalColumnWidth = 0;
  1070.       int index = 0;
  1071.       int[] columnWidths = new int[this.getColumnCount()];
  1072.       int[] columnMaxWidths = new int[this.getColumnCount()];
  1073.       int[] columnMinWidths = new int[this.getColumnCount()];
  1074.  
  1075.       for(Enumeration enumeration = this.getColumnModel().getColumns(); enumeration.hasMoreElements(); ++index) {
  1076.          TableColumn aColumn = (TableColumn)enumeration.nextElement();
  1077.          columnWidths[index] = aColumn.getWidth();
  1078.          columnMaxWidths[index] = aColumn.getMaxWidth();
  1079.          columnMinWidths[index] = aColumn.getMinWidth();
  1080.          totalColumnWidth += aColumn.getWidth() + intercellWidth;
  1081.       }
  1082.  
  1083.       int delta = frameWidth - totalColumnWidth;
  1084.       if (-1 > delta || delta > 1) {
  1085.          if (lastColumnOnly) {
  1086.             for(int var19 = this.getColumnCount() - 1; var19 >= 0; --var19) {
  1087.                int maxColumnDelta;
  1088.                if (delta > 0) {
  1089.                   maxColumnDelta = columnMaxWidths[var19] - columnWidths[var19];
  1090.                } else {
  1091.                   maxColumnDelta = columnMinWidths[var19] - columnWidths[var19];
  1092.                }
  1093.  
  1094.                if (Math.abs(maxColumnDelta) >= Math.abs(delta)) {
  1095.                   columnWidths[var19] += delta;
  1096.                   break;
  1097.                }
  1098.  
  1099.                columnWidths[var19] += maxColumnDelta;
  1100.                delta -= maxColumnDelta;
  1101.             }
  1102.          } else {
  1103.             float[] percentShare = new float[this.getColumnCount()];
  1104.             boolean stillHaveRoom = true;
  1105.  
  1106.             for(int var20 = 0; var20 < this.getColumnCount(); ++var20) {
  1107.                percentShare[var20] = (float)(columnWidths[var20] + intercellWidth) / (float)totalColumnWidth;
  1108.             }
  1109.  
  1110.             while(delta != 0 && stillHaveRoom) {
  1111.                int deltaRemainder = delta;
  1112.                stillHaveRoom = false;
  1113.  
  1114.                for(int var21 = 0; var21 < this.getColumnCount(); ++var21) {
  1115.                   int shareDelta = (int)Math.ceil((double)((float)delta * percentShare[var21]));
  1116.                   if (deltaRemainder == 0) {
  1117.                      break;
  1118.                   }
  1119.  
  1120.                   if (Math.abs(deltaRemainder) < Math.abs(shareDelta)) {
  1121.                      shareDelta = deltaRemainder;
  1122.                   }
  1123.  
  1124.                   int var25;
  1125.                   if (shareDelta > 0) {
  1126.                      var25 = columnMaxWidths[var21] - columnWidths[var21];
  1127.                   } else {
  1128.                      if (shareDelta >= 0) {
  1129.                         continue;
  1130.                      }
  1131.  
  1132.                      var25 = columnMinWidths[var21] - columnWidths[var21];
  1133.                   }
  1134.  
  1135.                   if (Math.abs(var25) >= Math.abs(shareDelta)) {
  1136.                      stillHaveRoom = true;
  1137.                      columnWidths[var21] += shareDelta;
  1138.                      deltaRemainder -= shareDelta;
  1139.                   } else if (var25 != 0) {
  1140.                      columnWidths[var21] += var25;
  1141.                      deltaRemainder -= var25;
  1142.                      percentShare[var21] = 0.0F;
  1143.                   }
  1144.                }
  1145.  
  1146.                delta = deltaRemainder;
  1147.                if (deltaRemainder != 0) {
  1148.                   float percentLeft = 0.0F;
  1149.  
  1150.                   for(int var22 = 0; var22 < this.getColumnCount(); ++var22) {
  1151.                      percentLeft += percentShare[var22];
  1152.                   }
  1153.  
  1154.                   float var27 = 100.0F / percentLeft;
  1155.  
  1156.                   for(int var23 = 0; var23 < this.getColumnCount(); ++var23) {
  1157.                      percentShare[var23] *= var27;
  1158.                   }
  1159.                }
  1160.             }
  1161.          }
  1162.  
  1163.          index = 0;
  1164.  
  1165.          for(Enumeration var26 = this.getColumnModel().getColumns(); var26.hasMoreElements(); ++index) {
  1166.             TableColumn var18 = (TableColumn)var26.nextElement();
  1167.             var18.setWidth(columnWidths[index]);
  1168.          }
  1169.  
  1170.       }
  1171.    }
  1172.  
  1173.    public void tableChanged(TableModelEvent e) {
  1174.       if (e != null && e.getFirstRow() != -1) {
  1175.          if (e.getType() == 1) {
  1176.             this.tableRowsInserted(e);
  1177.          } else if (e.getType() == -1) {
  1178.             this.tableRowsDeleted(e);
  1179.          } else {
  1180.             int modelColumn = e.getColumn();
  1181.             int start = e.getFirstRow();
  1182.             int end = e.getLastRow();
  1183.             if (start == -1) {
  1184.                start = 0;
  1185.                end = Integer.MAX_VALUE;
  1186.             }
  1187.  
  1188.             int rowHeight = this.getRowHeight() + this.rowMargin;
  1189.             Rectangle dirtyRegion;
  1190.             if (modelColumn == -1) {
  1191.                dirtyRegion = new Rectangle(0, start * rowHeight, this.getColumnModel().getTotalColumnWidth(), 0);
  1192.             } else {
  1193.                int column = this.convertColumnIndexToView(modelColumn);
  1194.                dirtyRegion = this.getCellRect(start, column, false);
  1195.             }
  1196.  
  1197.             if (end != Integer.MAX_VALUE) {
  1198.                dirtyRegion.height = (end - start + 1) * rowHeight;
  1199.                ((Component)this).repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
  1200.             } else {
  1201.                this.resizeAndRepaint();
  1202.             }
  1203.  
  1204.          }
  1205.       } else {
  1206.          this.clearSelection();
  1207.          if (this.getAutoCreateColumnsFromModel()) {
  1208.             this.createDefaultColumnsFromModel();
  1209.          }
  1210.  
  1211.          this.resizeAndRepaint();
  1212.          if (this.tableHeader != null) {
  1213.             this.tableHeader.resizeAndRepaint();
  1214.          }
  1215.  
  1216.       }
  1217.    }
  1218.  
  1219.    private void tableRowsDeleted(TableModelEvent e) {
  1220.       int start = e.getFirstRow();
  1221.       if (start < 0) {
  1222.          start = 0;
  1223.       }
  1224.  
  1225.       int rowHeight = this.getRowHeight() + this.rowMargin;
  1226.       Rectangle drawRect = new Rectangle(0, start * rowHeight, this.getColumnModel().getTotalColumnWidth(), (this.getRowCount() - start) * rowHeight);
  1227.       if (this.selectionModel != null) {
  1228.          int end = e.getLastRow();
  1229.          if (end < 0) {
  1230.             end = this.getRowCount() - 1;
  1231.          }
  1232.  
  1233.          this.selectionModel.removeIndexInterval(start, end);
  1234.       }
  1235.  
  1236.       ((JComponent)this).revalidate();
  1237.       ((Component)this).repaint(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
  1238.    }
  1239.  
  1240.    private void tableRowsInserted(TableModelEvent e) {
  1241.       int start = e.getFirstRow();
  1242.       if (start < 0) {
  1243.          start = 0;
  1244.       }
  1245.  
  1246.       int rowHeight = this.getRowHeight() + this.rowMargin;
  1247.       Rectangle drawRect = new Rectangle(0, start * rowHeight, this.getColumnModel().getTotalColumnWidth(), (this.getRowCount() - start) * rowHeight);
  1248.       if (this.selectionModel != null) {
  1249.          int end = e.getLastRow();
  1250.          if (end < 0) {
  1251.             end = this.getRowCount() - 1;
  1252.          }
  1253.  
  1254.          int length = end - start + 1;
  1255.          this.selectionModel.insertIndexInterval(start, length, true);
  1256.       }
  1257.  
  1258.       ((JComponent)this).revalidate();
  1259.       ((Component)this).repaint(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
  1260.    }
  1261.  
  1262.    private void updateSubComponentUI(Object componentShell) {
  1263.       if (componentShell != null) {
  1264.          Component component = null;
  1265.          if (componentShell instanceof Component) {
  1266.             component = (Component)componentShell;
  1267.          }
  1268.  
  1269.          if (componentShell instanceof DefaultCellEditor) {
  1270.             component = ((DefaultCellEditor)componentShell).getComponent();
  1271.          }
  1272.  
  1273.          if (component != null && component instanceof JComponent) {
  1274.             ((JComponent)component).updateUI();
  1275.          }
  1276.  
  1277.       }
  1278.    }
  1279.  
  1280.    public void updateUI() {
  1281.       TableColumnModel cm = this.getColumnModel();
  1282.  
  1283.       for(int column = 0; column < cm.getColumnCount(); ++column) {
  1284.          TableColumn aColumn = cm.getColumn(column);
  1285.          this.updateSubComponentUI(aColumn.getCellEditor());
  1286.       }
  1287.  
  1288.       Enumeration defaultEditors = this.defaultEditorsByColumnClass.elements();
  1289.  
  1290.       while(defaultEditors.hasMoreElements()) {
  1291.          this.updateSubComponentUI(defaultEditors.nextElement());
  1292.       }
  1293.  
  1294.       this.setUI((TableUI)UIManager.getUI(this));
  1295.       this.resizeAndRepaint();
  1296.       ((Container)this).invalidate();
  1297.    }
  1298.  
  1299.    public void valueChanged(ListSelectionEvent e) {
  1300.       int firstIndex = e.getFirstIndex();
  1301.       int lastIndex = e.getLastIndex();
  1302.       if (firstIndex == -1 && lastIndex == -1) {
  1303.          ((Component)this).repaint();
  1304.       }
  1305.  
  1306.       Rectangle firstRowRect = this.getCellRect(firstIndex, 0, false);
  1307.       Rectangle lastRowRect = this.getCellRect(lastIndex, this.getColumnCount(), false);
  1308.       Rectangle dirtyRegion = firstRowRect.union(lastRowRect);
  1309.       ((Component)this).repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
  1310.    }
  1311.  
  1312.    private void writeObject(ObjectOutputStream s) throws IOException {
  1313.       s.defaultWriteObject();
  1314.    }
  1315. }
  1316.